<html>

<head>
    <meta charset="utf-8">
    <title>修改密码</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="email=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <link rel="stylesheet" type="text/css" href="__HOME__/css/public.css" />
    <link rel="stylesheet" type="text/css" href="__HOME__/css/modify.css" />
    <script type="text/javascript" src="__HOME__/js/jquery.js"></script>
</head>
<body>
    <div class="top">
        <p>修改密码</p>
    </div>
    <div class="bottom">
        <p class="input"><input id="phoneNum" placeholder="请输入手机号" onkeyup="checkInput()"></p>
        <p class="input"><input id="passWord" type="passWord" placeholder="请输入原密码" onkeyup="checkInput()"></p>
        <p class="input"><input id="newpassWord" type="passWord" placeholder="请输入新密码" onkeyup="checkInput()"></p>
        <button class="btn_login" ><span>修改密码</span></button>
    </div>
</body>

</html>
<script type="text/javascript">
    $(".btn_login").click(function(){
        if($(".btn_login").hasClass("active")){
            vailPhone();
        }
           
    });
    
   function checkInput(){
        var phoneNum=$("#phoneNum").val();
        var passWord=$("#passWord").val();
        var newpassWord=$("#newpassWord").val();
        if (phoneNum && passWord&&newpassWord) {
            $(".btn_login").addClass("active");
        }else{
            $(".btn_login").removeClass("active");
        }
   }
   //验证手机号
    function vailPhone(){
      var phone = $("#phoneNum").val();
      var passWord=$("#passWord").val();
      var newpassWord=$("#newpassWord").val();
      var flag = false;
      var message = "";
      // var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;   
      var myreg =/^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/ ;   
      if(phone == ''){
        message = "手机号码不能为空！";
      }else if(phone.length !=11){
        message = "请输入有效的手机号码！";
      }else if(!myreg.test(phone)){
        message = "请输入有效的手机号码！";
      }else if(passWord== ''){
        message = "密码不能为空！";
      }else if(passWord.length<6){
        message = "密码必须是6位以上！";
      }else if(newpassWord== ''){
        message = "密码不能为空！";
      }else if(newpassWord.length<6){
        message = "密码必须是6位以上！";
      }else{
          flag = true;
      }
      if(!flag){
        //提示错误效果
        alert(message);
      }else{
       //正确后发送请求
         $.ajax({
               type: "post",
                  url: "/Register/domodify",
                  data: {"phone":phone, "passWord":passWord,"newpassWord":newpassWord},
                  dataType: "json",
                  success: function(data)
				  {
						if(data.status)
						{
							alert("密码改成功");
						}else{
							alert("密码修改失败");
						}
				  }
             });
      }
      return flag;
    }
</script>